package com.college_career_system.controller;


import com.alibaba.fastjson.JSONObject;
import com.college_career_system.pojo.dto.UserDTO;
import com.college_career_system.pojo.po.User;
import com.college_career_system.service.UserService;
import com.college_career_system.utils.Constant;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Empty
 * @since 2022-12-04
 */
@Controller
@RequestMapping("/user")
@CrossOrigin(origins = Constant.URL, allowCredentials = "true", maxAge = 3600)
public class UserController {
    private final UserService userService;


    public UserController(UserService userService) {
        this.userService = userService;
    }

    /**
     * 用户注册
     * @param user
     * @return
     */
    @PostMapping("/addUser")
    @ResponseBody
    /*整合加@RequestBody*/
    public String addUser( UserDTO user){
        return userService.addUser(user).toString();
    }

    /**
     * 查看用户自己已经提交的简历的记录
     * @param request
     * @return
     */
    @PostMapping("/selectMySubmit")
    @ResponseBody
    public JSONObject selectMySubmit(HttpServletRequest request) {
        return userService.selectMySubmit(request);
    }


    /**
     * 更新密码 传入新的密码
     * @param request
     * @param pwd
     * @return
     */
    @PostMapping("/updatePassWordById")
    @ResponseBody
    public  String updatePassWordById(HttpServletRequest request, String pwd) {
        return userService.updatePassWordById(request, pwd).toString();
    }
}

